import pygame
pygame.init()
from catClass import catClass
from MapClass import MapClass
from catConfig import catConfig
def main():
    screen = pygame.display.set_mode((800, 450),pygame.SRCALPHA)
    pygame.display.set_caption("The Cat game")

    # loading temporary map
    map = pygame.image.load("map.png").convert_alpha()
    screen.blit(map, (0, 0))
    
    #real map object
    map_obj = MapClass('l1')
    
    # crating hero
    cat = catClass()
    
    # creating hero 
    conf = catConfig();
    allSprites = pygame.sprite.Group(cat)
    
    # creating clock
    clock = pygame.time.Clock()
    keepGoing = True
    

    while keepGoing:
        clock.tick(40)
        
        # handle exit requests
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                keepGoing = False
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_ESCAPE:
                    keepGoing = False
                    
        #handle pressed keys
        key_action = conf.setActionBasedOnKey(pygame.key.get_pressed())
        # some funny printing raw action
        #print key_action
        
        #set actions for update
        cat.setDataForAction(key_action, pygame.time.get_ticks())
        
        allSprites.clear(screen, map)
        allSprites.update()
        allSprites.draw(screen)
        
        pygame.display.flip()
        
if __name__ == "__main__":
    main()